//
//  TFTableViewManager+refresh.m
//  JiLogistics
//
//  Created by zguanyu on 17/4/18.
//  Copyright © 2017年 zzzzz. All rights reserved.
//

#import "TFTableViewManager+refresh.h"
#import <TFDefine.h>
#import <TFTableViewManager+PullRefreshCapability.h>
#import <MJRefresh.h>

@implementation TFTableViewManager (refresh)

+ (void)load {
    [super load];
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        TFSwizzleMethod([self class], @selector(initTableViewPullRefresh:), @selector(jil_initTableViewPullRefresh:));
        TFSwizzleMethod([self class], @selector(startTableViewPullRefresh), @selector(jil_startTableViewPullRefresh));
        TFSwizzleMethod([self class], @selector(stopTableViewPullRefresh), @selector(jil_stopTableViewPullRefresh));
    });
}

- (void)jil_initTableViewPullRefresh:(void(^)(void))refreshBlock {
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:refreshBlock];
    self.tableView.mj_header = header;
}

- (void)jil_startTableViewPullRefresh {
    [self.tableView.mj_header beginRefreshing];
}

- (void)jil_stopTableViewPullRefresh {
     [self.tableView.mj_header endRefreshing];
}

@end
